package com.example.rabbitmq.consumer;

import com.example.rabbitmq.config.RabbitConfig;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
//@RabbitListener(queues = RabbitConfig.RABBITMQ_DEMO_NAME) //队列名称 可以有多个
//使用queuesToDeclare属性，如果不存在则会创建队列
@RabbitListener(queuesToDeclare = @Queue(RabbitConfig.RABBITMQ_DEMO_NAME))
public class RabbitConsumer {
    @RabbitHandler
    public void process(Map map){
        System.out.println("消费者从RabbitMQ服务端服务消费者信息:"+map.toString());
    }
}
